// 统一管理项目接口地址
import axios from "@/request/request";
import qs from "qs";

//获取精品推荐的数据
export const JingpinAPI = () => axios.get("/products/recommend");

//获取热门数据
export const RemenAPI = () => axios.get("/products/hot");

//发送短信验证码    params = {}
export const SendSMSAPI = (params) =>
  axios.post("/sendSMS", qs.stringify(params));

//登录请求
export const PhoneReginAPI = (params) =>
  axios.post("/phoneRegin", qs.stringify(params));

// console.log("序列化:", qs.stringify({ a: 10, b: 100 }));  //a=10&b=100

//微信扫码登录
export const WeiXinLoginAPI = (params) =>
  axios.post("/wechatUsers/PCLogin", qs.stringify(params));

//手机号关联微信登录
export const BindingAPI = (params) =>
  axios.post("/wechatUsers/binding", qs.stringify(params));

//获取用户信息
export const UserProfilesAPI = () => axios.get("/shop/userProfiles");

//请求产品详情信息 [地址参数]
export const GoodsDetailsAPI = (params) => axios.get(`/products/${params}`);

//加入购物车
export const AddToCartAPI = (params) =>
  axios.post("/shop/carts/add", qs.stringify(params));

//获取所有产品 [请求体] axios.get(url,{params:''})
//params = {did:1,type:xx,min:0...}
export const GoodsSearchAPI = (params) => axios.get("/products", { params }); //params:params

// 查看购物车 /shop/carts
export const CartsDateAPI = () => axios.get("/shop/carts");

// 删除购物车接口 /shop/carts?productIds={id}
export const DelCartAPI = (id) =>
  request.delete(`/shop/carts?productIds=${id}`);
